vulkan: Generate clip shaders from same source
authorBenjamin Otte <otte@redhat.com>
Tue, 17 Jan 2017 05:15:03 +0000 (06:15 +0100)
committerBenjamin Otte <otte@redhat.com>
Tue, 17 Jan 2017 05:17:55 +0000 (06:17 +0100)
Instead of having 3 different shaders for the different clipping
versions, just have one shader and use a preprocessor define to use
different clip functions.

That preprocessor define is set in the Makefile.

Also use foo.frag and foo.vert as the file extensions instead of using
foo.frag.glsl and foo.vert.glsl, as that's what glslc suggests as
extension.

51 files changed:
gsk/Makefile.am
gsk/resources/vulkan/blend-clip-rounded.frag.glsl [deleted file]
gsk/resources/vulkan/blend-clip-rounded.vert.glsl [deleted file]
gsk/resources/vulkan/blend-clip.frag.glsl [deleted file]
gsk/resources/vulkan/blend-clip.frag.spv
gsk/resources/vulkan/blend-clip.vert.glsl [deleted file]
gsk/resources/vulkan/blend-clip.vert.spv
gsk/resources/vulkan/blend.frag [new file with mode: 0644]
gsk/resources/vulkan/blend.frag.spv
gsk/resources/vulkan/blend.vert [new file with mode: 0644]
gsk/resources/vulkan/blend.vert.spv
gsk/resources/vulkan/border-clip-rounded.frag.glsl [deleted file]
gsk/resources/vulkan/border-clip-rounded.frag.spv
gsk/resources/vulkan/border-clip-rounded.vert.glsl [deleted file]
gsk/resources/vulkan/border-clip.frag.glsl [deleted file]
gsk/resources/vulkan/border-clip.frag.spv
gsk/resources/vulkan/border-clip.vert.glsl [deleted file]
gsk/resources/vulkan/border.frag [new file with mode: 0644]
gsk/resources/vulkan/border.frag.spv
gsk/resources/vulkan/border.vert [new file with mode: 0644]
gsk/resources/vulkan/border.vert.spv
gsk/resources/vulkan/color-clip-rounded.frag.glsl [deleted file]
gsk/resources/vulkan/color-clip-rounded.vert.glsl [deleted file]
gsk/resources/vulkan/color-clip.frag.glsl [deleted file]
gsk/resources/vulkan/color-clip.frag.spv
gsk/resources/vulkan/color-clip.vert.glsl [deleted file]
gsk/resources/vulkan/color-clip.vert.spv
gsk/resources/vulkan/color-matrix-clip-rounded.frag.glsl [deleted file]
gsk/resources/vulkan/color-matrix-clip-rounded.vert.glsl [deleted file]
gsk/resources/vulkan/color-matrix-clip.frag.glsl [deleted file]
gsk/resources/vulkan/color-matrix-clip.frag.spv
gsk/resources/vulkan/color-matrix-clip.vert.glsl [deleted file]
gsk/resources/vulkan/color-matrix-clip.vert.spv
gsk/resources/vulkan/color-matrix.frag [new file with mode: 0644]
gsk/resources/vulkan/color-matrix.frag.spv
gsk/resources/vulkan/color-matrix.vert [new file with mode: 0644]
gsk/resources/vulkan/color-matrix.vert.spv
gsk/resources/vulkan/color.frag [new file with mode: 0644]
gsk/resources/vulkan/color.frag.spv
gsk/resources/vulkan/color.vert [new file with mode: 0644]
gsk/resources/vulkan/color.vert.spv
gsk/resources/vulkan/linear-clip-rounded.frag.glsl [deleted file]
gsk/resources/vulkan/linear-clip-rounded.vert.glsl [deleted file]
gsk/resources/vulkan/linear-clip.frag.glsl [deleted file]
gsk/resources/vulkan/linear-clip.frag.spv
gsk/resources/vulkan/linear-clip.vert.glsl [deleted file]
gsk/resources/vulkan/linear-clip.vert.spv
gsk/resources/vulkan/linear.frag [new file with mode: 0644]
gsk/resources/vulkan/linear.frag.spv
gsk/resources/vulkan/linear.vert [new file with mode: 0644]
gsk/resources/vulkan/linear.vert.spv

index 06ed18e97e69e3eb52d1dc93a078a28d57c05a44..9d13253956b9813449fc1497ab735e0bcd8f8744 100644 (file)
@@ -62,39 +62,28 @@ gsk_private_vulkan_include_shaders = \
        resources/vulkan/clip.vert.glsl \
        resources/vulkan/constants.glsl \
        resources/vulkan/rounded-rect.glsl
+gsk_private_vulkan_fragment_shaders = \
+       resources/vulkan/blend.frag \
+       resources/vulkan/border.frag \
+       resources/vulkan/color.frag \
+       resources/vulkan/color-matrix.frag \
+       resources/vulkan/linear.frag
+gsk_private_vulkan_vertex_shaders = \
+       resources/vulkan/blend.vert \
+       resources/vulkan/border.vert \
+       resources/vulkan/color.vert \
+       resources/vulkan/color-matrix.vert \
+       resources/vulkan/linear.vert
 gsk_private_vulkan_shaders = \
-       resources/vulkan/blend-clip.frag.glsl \
-       resources/vulkan/blend-clip-rounded.frag.glsl \
-       resources/vulkan/blend-clip-rounded.vert.glsl \
-       resources/vulkan/blend-clip.vert.glsl \
-       resources/vulkan/blend.frag.glsl \
-       resources/vulkan/blend.vert.glsl \
-       resources/vulkan/border-clip.frag.glsl \
-       resources/vulkan/border-clip.vert.glsl \
-       resources/vulkan/border-clip-rounded.frag.glsl \
-       resources/vulkan/border-clip-rounded.vert.glsl \
-       resources/vulkan/border.frag.glsl \
-       resources/vulkan/border.vert.glsl \
-       resources/vulkan/color-clip.frag.glsl \
-       resources/vulkan/color-clip-rounded.frag.glsl \
-       resources/vulkan/color-clip-rounded.vert.glsl \
-       resources/vulkan/color-clip.vert.glsl \
-       resources/vulkan/color.frag.glsl \
-       resources/vulkan/color.vert.glsl \
-       resources/vulkan/color-matrix-clip.frag.glsl \
-       resources/vulkan/color-matrix-clip-rounded.frag.glsl \
-       resources/vulkan/color-matrix-clip-rounded.vert.glsl \
-       resources/vulkan/color-matrix-clip.vert.glsl \
-       resources/vulkan/color-matrix.frag.glsl \
-       resources/vulkan/color-matrix.vert.glsl \
-       resources/vulkan/linear-clip.frag.glsl \
-       resources/vulkan/linear-clip-rounded.frag.glsl \
-       resources/vulkan/linear-clip-rounded.vert.glsl \
-       resources/vulkan/linear-clip.vert.glsl \
-       resources/vulkan/linear.frag.glsl \
-       resources/vulkan/linear.vert.glsl
+       $(gsk_private_vulkan_fragment_shaders) \
+       $(gsk_private_vulkan_vertex_shaders)
 gsk_private_vulkan_compiled_shaders = \
-       $(gsk_private_vulkan_shaders:.glsl=.spv)
+       $(gsk_private_vulkan_fragment_shaders:.frag=.frag.spv) \
+       $(gsk_private_vulkan_vertex_shaders:.vert=.vert.spv) \
+       $(gsk_private_vulkan_fragment_shaders:.frag=-clip.frag.spv) \
+       $(gsk_private_vulkan_vertex_shaders:.vert=-clip.vert.spv) \
+       $(gsk_private_vulkan_fragment_shaders:.frag=-clip-rounded.frag.spv) \
+       $(gsk_private_vulkan_vertex_shaders:.vert=-clip-rounded.vert.spv)
 endif
 
 gsk_public_source_h = \
@@ -180,13 +169,29 @@ resource_files = \
        $(gsk_private_vulkan_compiled_shaders) \
        $(gsk_private_vulkan_shaders)
 
-resources/vulkan/%.frag.spv: resources/vulkan/%.frag.glsl
+resources/vulkan/%-clip-rounded.frag.spv: resources/vulkan/%.frag
        @if test -z "$(GLSLC)"; then echo "Missing glslc. See https://github.com/google/shaderc"; exit 1; fi
-       $(AM_V_GEN) $(GLSLC) -fshader-stage=fragment -o $@.tmp $< && mv $@.tmp $@
+       $(AM_V_GEN) $(GLSLC) -fshader-stage=fragment -DCLIP_ROUNDED_RECT -o $@.tmp $< && mv $@.tmp $@
 
-resources/vulkan/%.vert.spv: resources/vulkan/%.vert.glsl
+resources/vulkan/%-clip-rounded.vert.spv: resources/vulkan/%.vert
        @if test -z "$(GLSLC)"; then echo "Missing glslc. See https://github.com/google/shaderc"; exit 1; fi
-       $(AM_V_GEN) $(GLSLC) -fshader-stage=vertex -o $@.tmp $< && mv $@.tmp $@
+       $(AM_V_GEN) $(GLSLC) -fshader-stage=vertex -DCLIP_ROUNDED_RECT -o $@.tmp $< && mv $@.tmp $@
+
+resources/vulkan/%-clip.frag.spv: resources/vulkan/%.frag
+       @if test -z "$(GLSLC)"; then echo "Missing glslc. See https://github.com/google/shaderc"; exit 1; fi
+       $(AM_V_GEN) $(GLSLC) -fshader-stage=fragment -DCLIP_RECT -o $@.tmp $< && mv $@.tmp $@
+
+resources/vulkan/%-clip.vert.spv: resources/vulkan/%.vert
+       @if test -z "$(GLSLC)"; then echo "Missing glslc. See https://github.com/google/shaderc"; exit 1; fi
+       $(AM_V_GEN) $(GLSLC) -fshader-stage=vertex -DCLIP_RECT -o $@.tmp $< && mv $@.tmp $@
+
+resources/vulkan/%.frag.spv: resources/vulkan/%.frag
+       @if test -z "$(GLSLC)"; then echo "Missing glslc. See https://github.com/google/shaderc"; exit 1; fi
+       $(AM_V_GEN) $(GLSLC) -fshader-stage=fragment -DCLIP_NONE -o $@.tmp $< && mv $@.tmp $@
+
+resources/vulkan/%.vert.spv: resources/vulkan/%.vert
+       @if test -z "$(GLSLC)"; then echo "Missing glslc. See https://github.com/google/shaderc"; exit 1; fi
+       $(AM_V_GEN) $(GLSLC) -fshader-stage=vertex -DCLIP_NONE -o $@.tmp $< && mv $@.tmp $@
 
 gsk.resources.xml: Makefile.am
        $(AM_V_GEN) echo "<?xml version='1.0' encoding='UTF-8'?>" > $@; \
diff --git a/gsk/resources/vulkan/blend-clip-rounded.frag.glsl b/gsk/resources/vulkan/blend-clip-rounded.frag.glsl
deleted file mode 100644 (file)
index 81bd003..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#version 420 core
-
-#define CLIP_ROUNDED_RECT
-#include "clip.frag.glsl"
-
-layout(location = 0) in vec2 inPos;
-layout(location = 1) in vec2 inTexCoord;
-
-layout(set = 0, binding = 0) uniform sampler2D inTexture;
-
-layout(location = 0) out vec4 color;
-
-void main()
-{
-  color = clip (inPos, texture (inTexture, inTexCoord));
-}
diff --git a/gsk/resources/vulkan/blend-clip-rounded.vert.glsl b/gsk/resources/vulkan/blend-clip-rounded.vert.glsl
deleted file mode 100644 (file)
index fadf4b9..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-#version 420 core
-
-#define CLIP_ROUNDED_RECT
-#include "clip.vert.glsl"
-
-layout(location = 0) in vec4 inRect;
-layout(location = 1) in vec4 inTexRect;
-
-layout(location = 0) out vec2 outPos;
-layout(location = 1) out vec2 outTexCoord;
-
-out gl_PerVertex {
-  vec4 gl_Position;
-};
-
-vec2 offsets[6] = { vec2(0.0, 0.0),
-                    vec2(1.0, 0.0),
-                    vec2(0.0, 1.0),
-                    vec2(0.0, 1.0),
-                    vec2(1.0, 0.0),
-                    vec2(1.0, 1.0) };
-
-void main() {
-  vec4 rect = clip (inRect);
-  vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
-  gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
-
-  outPos = pos;
-
-  vec4 texrect = vec4((rect.xy - inRect.xy) / inRect.zw,
-                      rect.zw / inRect.zw);
-  texrect = vec4(inTexRect.xy + inTexRect.zw * texrect.xy,
-                 inTexRect.zw * texrect.zw);
-  outTexCoord = texrect.xy + texrect.zw * offsets[gl_VertexIndex];
-}
diff --git a/gsk/resources/vulkan/blend-clip.frag.glsl b/gsk/resources/vulkan/blend-clip.frag.glsl
deleted file mode 100644 (file)
index 4575c49..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#version 420 core
-
-layout(location = 0) in vec2 inTexCoord;
-
-layout(set = 0, binding = 0) uniform sampler2D inTexture;
-
-layout(location = 0) out vec4 color;
-
-void main()
-{
-  color = texture (inTexture, inTexCoord);
-}
index ef5dc6b6bfdf59d642833a33356328313b61db15..9d337c7202df7258b7fc248265994313eb2f63e7 100644 (file)
Binary files a/gsk/resources/vulkan/blend-clip.frag.spv and b/gsk/resources/vulkan/blend-clip.frag.spv differ
diff --git a/gsk/resources/vulkan/blend-clip.vert.glsl b/gsk/resources/vulkan/blend-clip.vert.glsl
deleted file mode 100644 (file)
index 88ad7c7..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#version 420 core
-
-#define CLIP_RECT
-#include "clip.vert.glsl"
-
-layout(location = 0) in vec4 inRect;
-layout(location = 1) in vec4 inTexRect;
-
-layout(location = 0) out vec2 outTexCoord;
-
-out gl_PerVertex {
-  vec4 gl_Position;
-};
-
-vec2 offsets[6] = { vec2(0.0, 0.0),
-                    vec2(1.0, 0.0),
-                    vec2(0.0, 1.0),
-                    vec2(0.0, 1.0),
-                    vec2(1.0, 0.0),
-                    vec2(1.0, 1.0) };
-
-void main() {
-  vec4 rect = clip (inRect);
-  vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
-  gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
-
-  vec4 texrect = vec4((rect.xy - inRect.xy) / inRect.zw,
-                      rect.zw / inRect.zw);
-  texrect = vec4(inTexRect.xy + inTexRect.zw * texrect.xy,
-                 inTexRect.zw * texrect.zw);
-  outTexCoord = texrect.xy + texrect.zw * offsets[gl_VertexIndex];
-}
index c8840cd5b8821c529c669a012918082c7241ec6c..cb6a9dadbbc3ffd4df85a5b174b2ad84f3807f08 100644 (file)
Binary files a/gsk/resources/vulkan/blend-clip.vert.spv and b/gsk/resources/vulkan/blend-clip.vert.spv differ
diff --git a/gsk/resources/vulkan/blend.frag b/gsk/resources/vulkan/blend.frag
new file mode 100644 (file)
index 0000000..ee9eb45
--- /dev/null
@@ -0,0 +1,15 @@
+#version 420 core
+
+#include "clip.frag.glsl"
+
+layout(location = 0) in vec2 inPos;
+layout(location = 1) in vec2 inTexCoord;
+
+layout(set = 0, binding = 0) uniform sampler2D inTexture;
+
+layout(location = 0) out vec4 color;
+
+void main()
+{
+  color = clip (inPos, texture (inTexture, inTexCoord));
+}
index 9dcff6d120b133e6c797fcb6a16399231a26177b..9d337c7202df7258b7fc248265994313eb2f63e7 100644 (file)
Binary files a/gsk/resources/vulkan/blend.frag.spv and b/gsk/resources/vulkan/blend.frag.spv differ
diff --git a/gsk/resources/vulkan/blend.vert b/gsk/resources/vulkan/blend.vert
new file mode 100644 (file)
index 0000000..c9bbb40
--- /dev/null
@@ -0,0 +1,34 @@
+#version 420 core
+
+#include "clip.vert.glsl"
+
+layout(location = 0) in vec4 inRect;
+layout(location = 1) in vec4 inTexRect;
+
+layout(location = 0) out vec2 outPos;
+layout(location = 1) out vec2 outTexCoord;
+
+out gl_PerVertex {
+  vec4 gl_Position;
+};
+
+vec2 offsets[6] = { vec2(0.0, 0.0),
+                    vec2(1.0, 0.0),
+                    vec2(0.0, 1.0),
+                    vec2(0.0, 1.0),
+                    vec2(1.0, 0.0),
+                    vec2(1.0, 1.0) };
+
+void main() {
+  vec4 rect = clip (inRect);
+  vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
+  gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
+
+  outPos = pos;
+
+  vec4 texrect = vec4((rect.xy - inRect.xy) / inRect.zw,
+                      rect.zw / inRect.zw);
+  texrect = vec4(inTexRect.xy + inTexRect.zw * texrect.xy,
+                 inTexRect.zw * texrect.zw);
+  outTexCoord = texrect.xy + texrect.zw * offsets[gl_VertexIndex];
+}
index 962a1b4e18904869424484829444034b01068556..e814653f9b8a513410d51cfced011c5954f212bf 100644 (file)
Binary files a/gsk/resources/vulkan/blend.vert.spv and b/gsk/resources/vulkan/blend.vert.spv differ
diff --git a/gsk/resources/vulkan/border-clip-rounded.frag.glsl b/gsk/resources/vulkan/border-clip-rounded.frag.glsl
deleted file mode 100644 (file)
index d31718a..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#version 420 core
-
-#include "constants.glsl"
-#include "rounded-rect.glsl"
-
-layout(location = 0) in vec2 inPos;
-layout(location = 1) in vec4 inColor;
-layout(location = 2) in vec4 inRect;
-layout(location = 3) in vec4 inCornerWidths;
-layout(location = 4) in vec4 inCornerHeights;
-layout(location = 5) in vec4 inBorderWidths;
-
-layout(location = 0) out vec4 color;
-
-vec4
-clip (vec4 color)
-{
-  RoundedRect r = RoundedRect(vec4(push.clip_bounds.xy, push.clip_bounds.xy + push.clip_bounds.zw), push.clip_widths, push.clip_heights);
-
-  return color * rounded_rect_coverage (r, inPos);
-}
-
-void main()
-{
-  RoundedRect routside = RoundedRect (vec4(inRect.xy, inRect.xy + inRect.zw), inCornerWidths, inCornerHeights);
-  RoundedRect rinside = rounded_rect_shrink (routside, inBorderWidths);
-  
-  float alpha = clamp (rounded_rect_coverage (routside, inPos) -
-                       rounded_rect_coverage (rinside, inPos),
-                       0.0, 1.0);
-  color = clip (inColor);
-}
index 3be544337c20d88fe019901d4f3975ba41abbcf5..690c02be05ad5375d1abfac52219f4b2b3d2434c 100644 (file)
Binary files a/gsk/resources/vulkan/border-clip-rounded.frag.spv and b/gsk/resources/vulkan/border-clip-rounded.frag.spv differ
diff --git a/gsk/resources/vulkan/border-clip-rounded.vert.glsl b/gsk/resources/vulkan/border-clip-rounded.vert.glsl
deleted file mode 100644 (file)
index ed11255..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-#version 420 core
-
-#define CLIP_ROUNDED_RECT
-#include "clip.vert.glsl"
-
-layout(location = 0) in vec4 inRect;
-layout(location = 1) in vec4 inCornerWidths;
-layout(location = 2) in vec4 inCornerHeights;
-layout(location = 3) in vec4 inBorderWidths;
-layout(location = 4) in mat4 inBorderColors;
-
-layout(location = 0) out vec2 outPos;
-layout(location = 1) out flat vec4 outColor;
-layout(location = 2) out flat vec4 outRect;
-layout(location = 3) out flat vec4 outCornerWidths;
-layout(location = 4) out flat vec4 outCornerHeights;
-layout(location = 5) out flat vec4 outBorderWidths;
-
-out gl_PerVertex {
-  vec4 gl_Position;
-};
-
-vec2 offsets[6] = { vec2(0.0, 0.0),
-                    vec2(1.0, 0.0),
-                    vec2(0.0, 1.0),
-                    vec2(1.0, 1.0),
-                    vec2(0.0, 1.0),
-                    vec2(1.0, 0.0) };
-
-#define TOP 0
-#define RIGHT 1
-#define BOTTOM 2
-#define LEFT 3
-
-#define TOP_LEFT 0
-#define TOP_RIGHT 1
-#define BOTTOM_RIGHT 2
-#define BOTTOM_LEFT 3
-
-#define SLICE_TOP_LEFT 0
-#define SLICE_TOP 1
-#define SLICE_TOP_RIGHT 2
-#define SLICE_RIGHT 3
-#define SLICE_BOTTOM_RIGHT 4
-#define SLICE_BOTTOM 5
-#define SLICE_BOTTOM_LEFT 6
-#define SLICE_LEFT 7
-
-void main() {
-  int slice_index = gl_VertexIndex / 6;
-  int vert_index = gl_VertexIndex % 6;
-
-  vec4 corner_widths = max (inCornerWidths, inBorderWidths.wyyw);
-  vec4 corner_heights = max (inCornerHeights, inBorderWidths.xxzz);
-
-  vec4 rect;
-
-  switch (slice_index)
-    {
-    case SLICE_TOP_LEFT:
-      rect = vec4(inRect.xy, corner_widths[TOP_LEFT], corner_heights[TOP_LEFT]);
-      vert_index = (vert_index + 3) % 6;
-      break;
-    case SLICE_TOP:
-      rect = vec4(inRect.x + corner_widths[TOP_LEFT], inRect.y, inRect.z - corner_widths[TOP_LEFT] - corner_widths[TOP_RIGHT], inBorderWidths[TOP]);
-      outColor = inBorderColors[TOP];
-      break;
-    case SLICE_TOP_RIGHT:
-      rect = vec4(inRect.x + inRect.z - corner_widths[TOP_RIGHT], inRect.y, corner_widths[TOP_RIGHT], corner_heights[TOP_RIGHT]);
-      break;
-    case SLICE_RIGHT:
-      rect = vec4(inRect.x + inRect.z - inBorderWidths[RIGHT], inRect.y + corner_heights[TOP_RIGHT], inBorderWidths[RIGHT], inRect.w - corner_heights[TOP_RIGHT] - corner_heights[BOTTOM_RIGHT]);
-      outColor = inBorderColors[RIGHT];
-      break;
-    case SLICE_BOTTOM_RIGHT:
-      rect = vec4(inRect.x + inRect.z - corner_widths[BOTTOM_RIGHT], inRect.y + inRect.w - corner_heights[BOTTOM_RIGHT], corner_widths[BOTTOM_RIGHT], corner_heights[BOTTOM_RIGHT]);
-      break;
-    case SLICE_BOTTOM:
-      rect = vec4(inRect.x + corner_widths[BOTTOM_LEFT], inRect.y + inRect.w - inBorderWidths[BOTTOM], inRect.z - corner_widths[BOTTOM_LEFT] - corner_widths[BOTTOM_RIGHT], inBorderWidths[BOTTOM]);
-      break;
-    case SLICE_BOTTOM_LEFT:
-      rect = vec4(inRect.x, inRect.y + inRect.w - corner_heights[BOTTOM_LEFT], corner_widths[BOTTOM_LEFT], corner_heights[BOTTOM_LEFT]);
-      vert_index = (vert_index + 3) % 6;
-      break;
-    case SLICE_LEFT:
-      rect = vec4(inRect.x, inRect.y + corner_heights[TOP_LEFT], inBorderWidths[LEFT], inRect.w - corner_heights[TOP_LEFT] - corner_heights[BOTTOM_LEFT]);
-      break;
-    }
-
-  rect = clip (rect);
-  vec2 pos;
-  if ((slice_index % 4) != 0 || (vert_index % 3) != 2)
-    pos = rect.xy + rect.zw * offsets[vert_index];
-  else
-    pos = rect.xy + rect.zw * vec2(1.0 - offsets[vert_index].x, offsets[vert_index].y);
-  gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
-  outColor = inBorderColors[((gl_VertexIndex / 3 + 15) / 4) % 4];
-  outPos = pos;
-  outRect = inRect;
-  outCornerWidths = inCornerWidths;
-  outCornerHeights = inCornerHeights;
-  outBorderWidths = inBorderWidths;
-}
diff --git a/gsk/resources/vulkan/border-clip.frag.glsl b/gsk/resources/vulkan/border-clip.frag.glsl
deleted file mode 100644 (file)
index 5f9d709..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#version 420 core
-
-#include "rounded-rect.glsl"
-
-layout(location = 0) in vec2 inPos;
-layout(location = 1) in flat vec4 inColor;
-layout(location = 2) in flat vec4 inRect;
-layout(location = 3) in flat vec4 inCornerWidths;
-layout(location = 4) in flat vec4 inCornerHeights;
-layout(location = 5) in flat vec4 inBorderWidths;
-
-layout(location = 0) out vec4 color;
-
-void main()
-{
-  RoundedRect routside = RoundedRect (vec4(inRect.xy, inRect.xy + inRect.zw), inCornerWidths, inCornerHeights);
-  RoundedRect rinside = rounded_rect_shrink (routside, inBorderWidths);
-  
-  float alpha = clamp (rounded_rect_coverage (routside, inPos) -
-                       rounded_rect_coverage (rinside, inPos),
-                       0.0, 1.0);
-  color = inColor * alpha;
-}
index ab43d3dec875290b475213235d1216dd3ea52201..1a3fda7d674c2c22673390ff18699cbda49b41d8 100644 (file)
Binary files a/gsk/resources/vulkan/border-clip.frag.spv and b/gsk/resources/vulkan/border-clip.frag.spv differ
diff --git a/gsk/resources/vulkan/border-clip.vert.glsl b/gsk/resources/vulkan/border-clip.vert.glsl
deleted file mode 100644 (file)
index 8e0fc83..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-#version 420 core
-
-#define CLIP_RECT
-#include "clip.vert.glsl"
-
-layout(location = 0) in vec4 inRect;
-layout(location = 1) in vec4 inCornerWidths;
-layout(location = 2) in vec4 inCornerHeights;
-layout(location = 3) in vec4 inBorderWidths;
-layout(location = 4) in mat4 inBorderColors;
-
-layout(location = 0) out vec2 outPos;
-layout(location = 1) out flat vec4 outColor;
-layout(location = 2) out flat vec4 outRect;
-layout(location = 3) out flat vec4 outCornerWidths;
-layout(location = 4) out flat vec4 outCornerHeights;
-layout(location = 5) out flat vec4 outBorderWidths;
-
-out gl_PerVertex {
-  vec4 gl_Position;
-};
-
-vec2 offsets[6] = { vec2(0.0, 0.0),
-                    vec2(1.0, 0.0),
-                    vec2(0.0, 1.0),
-                    vec2(1.0, 1.0),
-                    vec2(0.0, 1.0),
-                    vec2(1.0, 0.0) };
-
-#define TOP 0
-#define RIGHT 1
-#define BOTTOM 2
-#define LEFT 3
-
-#define TOP_LEFT 0
-#define TOP_RIGHT 1
-#define BOTTOM_RIGHT 2
-#define BOTTOM_LEFT 3
-
-#define SLICE_TOP_LEFT 0
-#define SLICE_TOP 1
-#define SLICE_TOP_RIGHT 2
-#define SLICE_RIGHT 3
-#define SLICE_BOTTOM_RIGHT 4
-#define SLICE_BOTTOM 5
-#define SLICE_BOTTOM_LEFT 6
-#define SLICE_LEFT 7
-
-void main() {
-  int slice_index = gl_VertexIndex / 6;
-  int vert_index = gl_VertexIndex % 6;
-
-  vec4 corner_widths = max (inCornerWidths, inBorderWidths.wyyw);
-  vec4 corner_heights = max (inCornerHeights, inBorderWidths.xxzz);
-
-  vec4 rect;
-
-  switch (slice_index)
-    {
-    case SLICE_TOP_LEFT:
-      rect = vec4(inRect.xy, corner_widths[TOP_LEFT], corner_heights[TOP_LEFT]);
-      vert_index = (vert_index + 3) % 6;
-      break;
-    case SLICE_TOP:
-      rect = vec4(inRect.x + corner_widths[TOP_LEFT], inRect.y, inRect.z - corner_widths[TOP_LEFT] - corner_widths[TOP_RIGHT], inBorderWidths[TOP]);
-      outColor = inBorderColors[TOP];
-      break;
-    case SLICE_TOP_RIGHT:
-      rect = vec4(inRect.x + inRect.z - corner_widths[TOP_RIGHT], inRect.y, corner_widths[TOP_RIGHT], corner_heights[TOP_RIGHT]);
-      break;
-    case SLICE_RIGHT:
-      rect = vec4(inRect.x + inRect.z - inBorderWidths[RIGHT], inRect.y + corner_heights[TOP_RIGHT], inBorderWidths[RIGHT], inRect.w - corner_heights[TOP_RIGHT] - corner_heights[BOTTOM_RIGHT]);
-      outColor = inBorderColors[RIGHT];
-      break;
-    case SLICE_BOTTOM_RIGHT:
-      rect = vec4(inRect.x + inRect.z - corner_widths[BOTTOM_RIGHT], inRect.y + inRect.w - corner_heights[BOTTOM_RIGHT], corner_widths[BOTTOM_RIGHT], corner_heights[BOTTOM_RIGHT]);
-      break;
-    case SLICE_BOTTOM:
-      rect = vec4(inRect.x + corner_widths[BOTTOM_LEFT], inRect.y + inRect.w - inBorderWidths[BOTTOM], inRect.z - corner_widths[BOTTOM_LEFT] - corner_widths[BOTTOM_RIGHT], inBorderWidths[BOTTOM]);
-      break;
-    case SLICE_BOTTOM_LEFT:
-      rect = vec4(inRect.x, inRect.y + inRect.w - corner_heights[BOTTOM_LEFT], corner_widths[BOTTOM_LEFT], corner_heights[BOTTOM_LEFT]);
-      vert_index = (vert_index + 3) % 6;
-      break;
-    case SLICE_LEFT:
-      rect = vec4(inRect.x, inRect.y + corner_heights[TOP_LEFT], inBorderWidths[LEFT], inRect.w - corner_heights[TOP_LEFT] - corner_heights[BOTTOM_LEFT]);
-      break;
-    }
-
-  rect = clip (rect);
-  vec2 pos;
-  if ((slice_index % 4) != 0 || (vert_index % 3) != 2)
-    pos = rect.xy + rect.zw * offsets[vert_index];
-  else
-    pos = rect.xy + rect.zw * vec2(1.0 - offsets[vert_index].x, offsets[vert_index].y);
-  gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
-  outColor = inBorderColors[((gl_VertexIndex / 3 + 15) / 4) % 4];
-  outPos = pos;
-  outRect = inRect;
-  outCornerWidths = inCornerWidths;
-  outCornerHeights = inCornerHeights;
-  outBorderWidths = inBorderWidths;
-}
diff --git a/gsk/resources/vulkan/border.frag b/gsk/resources/vulkan/border.frag
new file mode 100644 (file)
index 0000000..988b1f6
--- /dev/null
@@ -0,0 +1,24 @@
+#version 420 core
+
+#include "clip.frag.glsl"
+#include "rounded-rect.glsl"
+
+layout(location = 0) in vec2 inPos;
+layout(location = 1) in vec4 inColor;
+layout(location = 2) in vec4 inRect;
+layout(location = 3) in vec4 inCornerWidths;
+layout(location = 4) in vec4 inCornerHeights;
+layout(location = 5) in vec4 inBorderWidths;
+
+layout(location = 0) out vec4 color;
+
+void main()
+{
+  RoundedRect routside = RoundedRect (vec4(inRect.xy, inRect.xy + inRect.zw), inCornerWidths, inCornerHeights);
+  RoundedRect rinside = rounded_rect_shrink (routside, inBorderWidths);
+  
+  float alpha = clamp (rounded_rect_coverage (routside, inPos) -
+                       rounded_rect_coverage (rinside, inPos),
+                       0.0, 1.0);
+  color = clip (inPos, inColor * alpha);
+}
index ab43d3dec875290b475213235d1216dd3ea52201..1a3fda7d674c2c22673390ff18699cbda49b41d8 100644 (file)
Binary files a/gsk/resources/vulkan/border.frag.spv and b/gsk/resources/vulkan/border.frag.spv differ
diff --git a/gsk/resources/vulkan/border.vert b/gsk/resources/vulkan/border.vert
new file mode 100644 (file)
index 0000000..b37ea9e
--- /dev/null
@@ -0,0 +1,102 @@
+#version 420 core
+
+#include "clip.vert.glsl"
+
+layout(location = 0) in vec4 inRect;
+layout(location = 1) in vec4 inCornerWidths;
+layout(location = 2) in vec4 inCornerHeights;
+layout(location = 3) in vec4 inBorderWidths;
+layout(location = 4) in mat4 inBorderColors;
+
+layout(location = 0) out vec2 outPos;
+layout(location = 1) out flat vec4 outColor;
+layout(location = 2) out flat vec4 outRect;
+layout(location = 3) out flat vec4 outCornerWidths;
+layout(location = 4) out flat vec4 outCornerHeights;
+layout(location = 5) out flat vec4 outBorderWidths;
+
+out gl_PerVertex {
+  vec4 gl_Position;
+};
+
+vec2 offsets[6] = { vec2(0.0, 0.0),
+                    vec2(1.0, 0.0),
+                    vec2(0.0, 1.0),
+                    vec2(1.0, 1.0),
+                    vec2(0.0, 1.0),
+                    vec2(1.0, 0.0) };
+
+#define TOP 0
+#define RIGHT 1
+#define BOTTOM 2
+#define LEFT 3
+
+#define TOP_LEFT 0
+#define TOP_RIGHT 1
+#define BOTTOM_RIGHT 2
+#define BOTTOM_LEFT 3
+
+#define SLICE_TOP_LEFT 0
+#define SLICE_TOP 1
+#define SLICE_TOP_RIGHT 2
+#define SLICE_RIGHT 3
+#define SLICE_BOTTOM_RIGHT 4
+#define SLICE_BOTTOM 5
+#define SLICE_BOTTOM_LEFT 6
+#define SLICE_LEFT 7
+
+void main() {
+  int slice_index = gl_VertexIndex / 6;
+  int vert_index = gl_VertexIndex % 6;
+
+  vec4 corner_widths = max (inCornerWidths, inBorderWidths.wyyw);
+  vec4 corner_heights = max (inCornerHeights, inBorderWidths.xxzz);
+
+  vec4 rect;
+
+  switch (slice_index)
+    {
+    case SLICE_TOP_LEFT:
+      rect = vec4(inRect.xy, corner_widths[TOP_LEFT], corner_heights[TOP_LEFT]);
+      vert_index = (vert_index + 3) % 6;
+      break;
+    case SLICE_TOP:
+      rect = vec4(inRect.x + corner_widths[TOP_LEFT], inRect.y, inRect.z - corner_widths[TOP_LEFT] - corner_widths[TOP_RIGHT], inBorderWidths[TOP]);
+      outColor = inBorderColors[TOP];
+      break;
+    case SLICE_TOP_RIGHT:
+      rect = vec4(inRect.x + inRect.z - corner_widths[TOP_RIGHT], inRect.y, corner_widths[TOP_RIGHT], corner_heights[TOP_RIGHT]);
+      break;
+    case SLICE_RIGHT:
+      rect = vec4(inRect.x + inRect.z - inBorderWidths[RIGHT], inRect.y + corner_heights[TOP_RIGHT], inBorderWidths[RIGHT], inRect.w - corner_heights[TOP_RIGHT] - corner_heights[BOTTOM_RIGHT]);
+      outColor = inBorderColors[RIGHT];
+      break;
+    case SLICE_BOTTOM_RIGHT:
+      rect = vec4(inRect.x + inRect.z - corner_widths[BOTTOM_RIGHT], inRect.y + inRect.w - corner_heights[BOTTOM_RIGHT], corner_widths[BOTTOM_RIGHT], corner_heights[BOTTOM_RIGHT]);
+      break;
+    case SLICE_BOTTOM:
+      rect = vec4(inRect.x + corner_widths[BOTTOM_LEFT], inRect.y + inRect.w - inBorderWidths[BOTTOM], inRect.z - corner_widths[BOTTOM_LEFT] - corner_widths[BOTTOM_RIGHT], inBorderWidths[BOTTOM]);
+      break;
+    case SLICE_BOTTOM_LEFT:
+      rect = vec4(inRect.x, inRect.y + inRect.w - corner_heights[BOTTOM_LEFT], corner_widths[BOTTOM_LEFT], corner_heights[BOTTOM_LEFT]);
+      vert_index = (vert_index + 3) % 6;
+      break;
+    case SLICE_LEFT:
+      rect = vec4(inRect.x, inRect.y + corner_heights[TOP_LEFT], inBorderWidths[LEFT], inRect.w - corner_heights[TOP_LEFT] - corner_heights[BOTTOM_LEFT]);
+      break;
+    }
+
+  rect = clip (rect);
+  vec2 pos;
+  if ((slice_index % 4) != 0 || (vert_index % 3) != 2)
+    pos = rect.xy + rect.zw * offsets[vert_index];
+  else
+    pos = rect.xy + rect.zw * vec2(1.0 - offsets[vert_index].x, offsets[vert_index].y);
+  gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
+  outColor = inBorderColors[((gl_VertexIndex / 3 + 15) / 4) % 4];
+  outPos = pos;
+  outRect = inRect;
+  outCornerWidths = inCornerWidths;
+  outCornerHeights = inCornerHeights;
+  outBorderWidths = inBorderWidths;
+}
index 6a6cf93865891ea37a906dd086e750db87a14dc2..dfa95f1b596140d5f4fef5d428ae2daf1f0f1844 100644 (file)
Binary files a/gsk/resources/vulkan/border.vert.spv and b/gsk/resources/vulkan/border.vert.spv differ
diff --git a/gsk/resources/vulkan/color-clip-rounded.frag.glsl b/gsk/resources/vulkan/color-clip-rounded.frag.glsl
deleted file mode 100644 (file)
index b66001c..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#version 420 core
-
-#define CLIP_ROUNDED_RECT
-#include "clip.frag.glsl"
-
-layout(location = 0) in vec2 inPos;
-layout(location = 1) in vec4 inColor;
-
-layout(location = 0) out vec4 color;
-
-void main()
-{
-  color = clip (inPos, vec4(inColor.rgb * inColor.a, inColor.a));
-}
diff --git a/gsk/resources/vulkan/color-clip-rounded.vert.glsl b/gsk/resources/vulkan/color-clip-rounded.vert.glsl
deleted file mode 100644 (file)
index 7f7a1e9..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#version 420 core
-
-#define CLIP_ROUNDED_RECT
-#include "clip.vert.glsl"
-
-layout(location = 0) in vec4 inRect;
-layout(location = 1) in vec4 inColor;
-
-layout(location = 0) out vec2 outPos;
-layout(location = 1) out flat vec4 outColor;
-
-out gl_PerVertex {
-  vec4 gl_Position;
-};
-
-vec2 offsets[6] = { vec2(0.0, 0.0),
-                    vec2(1.0, 0.0),
-                    vec2(0.0, 1.0),
-                    vec2(0.0, 1.0),
-                    vec2(1.0, 0.0),
-                    vec2(1.0, 1.0) };
-
-void main() {
-  vec4 rect = clip (inRect);
-
-  vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
-  gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
-  outPos = pos;
-  outColor = inColor;
-}
diff --git a/gsk/resources/vulkan/color-clip.frag.glsl b/gsk/resources/vulkan/color-clip.frag.glsl
deleted file mode 100644 (file)
index 218ee85..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#version 420 core
-
-layout(location = 0) in vec4 inColor;
-
-layout(location = 0) out vec4 color;
-
-void main()
-{
-    color = vec4(inColor.rgb * inColor.a, inColor.a);
-}
index 29bbae9dfd0753ec73d49efa0eefb8c71d069d59..d3ef64ef49738ce7eb0b159e7147316852e50dc3 100644 (file)
Binary files a/gsk/resources/vulkan/color-clip.frag.spv and b/gsk/resources/vulkan/color-clip.frag.spv differ
diff --git a/gsk/resources/vulkan/color-clip.vert.glsl b/gsk/resources/vulkan/color-clip.vert.glsl
deleted file mode 100644 (file)
index a869b8a..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#version 420 core
-
-#define CLIP_RECT
-#include "clip.vert.glsl"
-
-layout(location = 0) in vec4 inRect;
-layout(location = 1) in vec4 inColor;
-
-out gl_PerVertex {
-  vec4 gl_Position;
-};
-
-layout(location = 0) out vec4 outColor;
-
-vec2 offsets[6] = { vec2(0.0, 0.0),
-                    vec2(1.0, 0.0),
-                    vec2(0.0, 1.0),
-                    vec2(0.0, 1.0),
-                    vec2(1.0, 0.0),
-                    vec2(1.0, 1.0) };
-
-void main() {
-  vec4 rect = clip (inRect);
-
-  vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
-  gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
-  outColor = inColor;
-}
index 0b2711b2d1fafb954087b772fa9ea04c163f6a41..daaf33aa22ef03465f0c6117a5af985f64954f68 100644 (file)
Binary files a/gsk/resources/vulkan/color-clip.vert.spv and b/gsk/resources/vulkan/color-clip.vert.spv differ
diff --git a/gsk/resources/vulkan/color-matrix-clip-rounded.frag.glsl b/gsk/resources/vulkan/color-matrix-clip-rounded.frag.glsl
deleted file mode 100644 (file)
index 88057c7..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-#version 420 core
-
-#define CLIP_ROUNDED_RECT
-#include "clip.frag.glsl"
-
-layout(location = 0) in vec2 inPos;
-layout(location = 1) in vec2 inTexCoord;
-layout(location = 2) in flat mat4 inColorMatrix;
-layout(location = 6) in flat vec4 inColorOffset;
-
-layout(set = 0, binding = 0) uniform sampler2D inTexture;
-
-layout(location = 0) out vec4 color;
-
-vec4
-color_matrix (vec4 color, mat4 color_matrix, vec4 color_offset)
-{
-  /* unpremultiply */
-  if (color.a != 0.0)
-    color.rgb /= color.a;
-
-  color = color_matrix * color + color_offset;
-  color = clamp(color, 0.0, 1.0);
-
-  /* premultiply */
-  if (color.a != 0.0)
-    color.rgb *= color.a;
-
-  return color;
-}
-
-void main()
-{
-  color = clip (inPos, color_matrix (texture (inTexture, inTexCoord), inColorMatrix, inColorOffset));
-}
diff --git a/gsk/resources/vulkan/color-matrix-clip-rounded.vert.glsl b/gsk/resources/vulkan/color-matrix-clip-rounded.vert.glsl
deleted file mode 100644 (file)
index 3888b7e..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#version 420 core
-
-#define CLIP_ROUNDED_RECT
-#include "clip.vert.glsl"
-
-layout(location = 0) in vec4 inRect;
-layout(location = 1) in vec4 inTexRect;
-layout(location = 2) in mat4 inColorMatrix;
-layout(location = 6) in vec4 inColorOffset;
-
-layout(location = 0) out vec2 outPos;
-layout(location = 1) out vec2 outTexCoord;
-layout(location = 2) out flat mat4 outColorMatrix;
-layout(location = 6) out flat vec4 outColorOffset;
-
-out gl_PerVertex {
-  vec4 gl_Position;
-};
-
-vec2 offsets[6] = { vec2(0.0, 0.0),
-                    vec2(1.0, 0.0),
-                    vec2(0.0, 1.0),
-                    vec2(0.0, 1.0),
-                    vec2(1.0, 0.0),
-                    vec2(1.0, 1.0) };
-
-void main() {
-  vec4 rect = clip (inRect);
-  vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
-  gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
-
-  outPos = pos;
-
-  vec4 texrect = vec4((rect.xy - inRect.xy) / inRect.zw,
-                      rect.zw / inRect.zw);
-  texrect = vec4(inTexRect.xy + inTexRect.zw * texrect.xy,
-                 inTexRect.zw * texrect.zw);
-  outTexCoord = texrect.xy + texrect.zw * offsets[gl_VertexIndex];
-  outColorMatrix = inColorMatrix;
-  outColorOffset = inColorOffset;
-}
diff --git a/gsk/resources/vulkan/color-matrix-clip.frag.glsl b/gsk/resources/vulkan/color-matrix-clip.frag.glsl
deleted file mode 100644 (file)
index 21a324e..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#version 420 core
-
-layout(location = 0) in vec2 inTexCoord;
-layout(location = 1) in flat mat4 inColorMatrix;
-layout(location = 5) in flat vec4 inColorOffset;
-
-layout(set = 0, binding = 0) uniform sampler2D inTexture;
-
-layout(location = 0) out vec4 color;
-
-vec4
-color_matrix (vec4 color, mat4 color_matrix, vec4 color_offset)
-{
-  /* unpremultiply */
-  if (color.a != 0.0)
-    color.rgb /= color.a;
-
-  color = color_matrix * color + color_offset;
-  color = clamp(color, 0.0, 1.0);
-
-  /* premultiply */
-  if (color.a != 0.0)
-    color.rgb *= color.a;
-
-  return color;
-}
-
-void main()
-{
-  color = color_matrix (texture (inTexture, inTexCoord), inColorMatrix, inColorOffset);
-}
index 266c8777f56187e47dba4756918856154274e0b5..ec29f263bbba778e7ab642765ce84ce77d97e369 100644 (file)
Binary files a/gsk/resources/vulkan/color-matrix-clip.frag.spv and b/gsk/resources/vulkan/color-matrix-clip.frag.spv differ
diff --git a/gsk/resources/vulkan/color-matrix-clip.vert.glsl b/gsk/resources/vulkan/color-matrix-clip.vert.glsl
deleted file mode 100644 (file)
index 6ae0817..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-#version 420 core
-
-#define CLIP_RECT
-#include "clip.vert.glsl"
-
-layout(location = 0) in vec4 inRect;
-layout(location = 1) in vec4 inTexRect;
-layout(location = 2) in mat4 inColorMatrix;
-layout(location = 6) in vec4 inColorOffset;
-
-layout(location = 0) out vec2 outTexCoord;
-layout(location = 1) out flat mat4 outColorMatrix;
-layout(location = 5) out flat vec4 outColorOffset;
-
-out gl_PerVertex {
-  vec4 gl_Position;
-};
-
-vec2 offsets[6] = { vec2(0.0, 0.0),
-                    vec2(1.0, 0.0),
-                    vec2(0.0, 1.0),
-                    vec2(0.0, 1.0),
-                    vec2(1.0, 0.0),
-                    vec2(1.0, 1.0) };
-
-void main() {
-  vec4 rect = clip (inRect);
-  vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
-  gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
-
-  vec4 texrect = vec4((rect.xy - inRect.xy) / inRect.zw,
-                      rect.zw / inRect.zw);
-  texrect = vec4(inTexRect.xy + inTexRect.zw * texrect.xy,
-                 inTexRect.zw * texrect.zw);
-  outTexCoord = texrect.xy + texrect.zw * offsets[gl_VertexIndex];
-  outColorMatrix = inColorMatrix;
-  outColorOffset = inColorOffset;
-}
index 20b615e67b8637b81599e794d7dae7015ab5934f..f4951f653007b9ecf37bb1ac220e8a56dacaadf3 100644 (file)
Binary files a/gsk/resources/vulkan/color-matrix-clip.vert.spv and b/gsk/resources/vulkan/color-matrix-clip.vert.spv differ
diff --git a/gsk/resources/vulkan/color-matrix.frag b/gsk/resources/vulkan/color-matrix.frag
new file mode 100644 (file)
index 0000000..00b7947
--- /dev/null
@@ -0,0 +1,34 @@
+#version 420 core
+
+#include "clip.frag.glsl"
+
+layout(location = 0) in vec2 inPos;
+layout(location = 1) in vec2 inTexCoord;
+layout(location = 2) in flat mat4 inColorMatrix;
+layout(location = 6) in flat vec4 inColorOffset;
+
+layout(set = 0, binding = 0) uniform sampler2D inTexture;
+
+layout(location = 0) out vec4 color;
+
+vec4
+color_matrix (vec4 color, mat4 color_matrix, vec4 color_offset)
+{
+  /* unpremultiply */
+  if (color.a != 0.0)
+    color.rgb /= color.a;
+
+  color = color_matrix * color + color_offset;
+  color = clamp(color, 0.0, 1.0);
+
+  /* premultiply */
+  if (color.a != 0.0)
+    color.rgb *= color.a;
+
+  return color;
+}
+
+void main()
+{
+  color = clip (inPos, color_matrix (texture (inTexture, inTexCoord), inColorMatrix, inColorOffset));
+}
index 266c8777f56187e47dba4756918856154274e0b5..ec29f263bbba778e7ab642765ce84ce77d97e369 100644 (file)
Binary files a/gsk/resources/vulkan/color-matrix.frag.spv and b/gsk/resources/vulkan/color-matrix.frag.spv differ
diff --git a/gsk/resources/vulkan/color-matrix.vert b/gsk/resources/vulkan/color-matrix.vert
new file mode 100644 (file)
index 0000000..eb3f4fa
--- /dev/null
@@ -0,0 +1,40 @@
+#version 420 core
+
+#include "clip.vert.glsl"
+
+layout(location = 0) in vec4 inRect;
+layout(location = 1) in vec4 inTexRect;
+layout(location = 2) in mat4 inColorMatrix;
+layout(location = 6) in vec4 inColorOffset;
+
+layout(location = 0) out vec2 outPos;
+layout(location = 1) out vec2 outTexCoord;
+layout(location = 2) out flat mat4 outColorMatrix;
+layout(location = 6) out flat vec4 outColorOffset;
+
+out gl_PerVertex {
+  vec4 gl_Position;
+};
+
+vec2 offsets[6] = { vec2(0.0, 0.0),
+                    vec2(1.0, 0.0),
+                    vec2(0.0, 1.0),
+                    vec2(0.0, 1.0),
+                    vec2(1.0, 0.0),
+                    vec2(1.0, 1.0) };
+
+void main() {
+  vec4 rect = clip (inRect);
+  vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
+  gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
+
+  outPos = pos;
+
+  vec4 texrect = vec4((rect.xy - inRect.xy) / inRect.zw,
+                      rect.zw / inRect.zw);
+  texrect = vec4(inTexRect.xy + inTexRect.zw * texrect.xy,
+                 inTexRect.zw * texrect.zw);
+  outTexCoord = texrect.xy + texrect.zw * offsets[gl_VertexIndex];
+  outColorMatrix = inColorMatrix;
+  outColorOffset = inColorOffset;
+}
index fa89276b21107d266635f7c9d3aa42a87c3ba3f0..89176d44e620f2ab293b9e4444defce6984f1d87 100644 (file)
Binary files a/gsk/resources/vulkan/color-matrix.vert.spv and b/gsk/resources/vulkan/color-matrix.vert.spv differ
diff --git a/gsk/resources/vulkan/color.frag b/gsk/resources/vulkan/color.frag
new file mode 100644 (file)
index 0000000..6b299df
--- /dev/null
@@ -0,0 +1,13 @@
+#version 420 core
+
+#include "clip.frag.glsl"
+
+layout(location = 0) in vec2 inPos;
+layout(location = 1) in vec4 inColor;
+
+layout(location = 0) out vec4 color;
+
+void main()
+{
+  color = clip (inPos, vec4(inColor.rgb * inColor.a, inColor.a));
+}
index 29bbae9dfd0753ec73d49efa0eefb8c71d069d59..d3ef64ef49738ce7eb0b159e7147316852e50dc3 100644 (file)
Binary files a/gsk/resources/vulkan/color.frag.spv and b/gsk/resources/vulkan/color.frag.spv differ
diff --git a/gsk/resources/vulkan/color.vert b/gsk/resources/vulkan/color.vert
new file mode 100644 (file)
index 0000000..ce85ea7
--- /dev/null
@@ -0,0 +1,29 @@
+#version 420 core
+
+#include "clip.vert.glsl"
+
+layout(location = 0) in vec4 inRect;
+layout(location = 1) in vec4 inColor;
+
+layout(location = 0) out vec2 outPos;
+layout(location = 1) out flat vec4 outColor;
+
+out gl_PerVertex {
+  vec4 gl_Position;
+};
+
+vec2 offsets[6] = { vec2(0.0, 0.0),
+                    vec2(1.0, 0.0),
+                    vec2(0.0, 1.0),
+                    vec2(0.0, 1.0),
+                    vec2(1.0, 0.0),
+                    vec2(1.0, 1.0) };
+
+void main() {
+  vec4 rect = clip (inRect);
+
+  vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
+  gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
+  outPos = pos;
+  outColor = inColor;
+}
index 05d74a6b0b414c2f1816ed2dac6da05d4fbcbb97..4a0b396584d78136335392c93734318aafbdb0a5 100644 (file)
Binary files a/gsk/resources/vulkan/color.vert.spv and b/gsk/resources/vulkan/color.vert.spv differ
diff --git a/gsk/resources/vulkan/linear-clip-rounded.frag.glsl b/gsk/resources/vulkan/linear-clip-rounded.frag.glsl
deleted file mode 100644 (file)
index 1fbf095..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-#version 420 core
-
-#define CLIP_ROUNDED_RECT
-#include "clip.frag.glsl"
-
-struct ColorStop {
-  float offset;
-  vec4 color;
-};
-
-layout(location = 0) in vec2 inPos;
-layout(location = 1) in float inGradientPos;
-layout(location = 2) in flat int inRepeating;
-layout(location = 3) in flat int inStopCount;
-layout(location = 4) in flat ColorStop inStops[8];
-
-layout(location = 0) out vec4 outColor;
-
-void main()
-{
-  float pos;
-  if (inRepeating != 0)
-    pos = fract (inGradientPos);
-  else
-    pos = clamp (inGradientPos, 0, 1);
-
-  vec4 color = inStops[0].color;
-  int n = clamp (inStopCount, 2, 8);
-  for (int i = 1; i < n; i++)
-    {
-      if (inStops[i].offset > inStops[i-1].offset)
-        color = mix (color, inStops[i].color, clamp((pos - inStops[i-1].offset) / (inStops[i].offset - inStops[i-1].offset), 0, 1));
-    }
-  
-  //outColor = vec4(pos, pos, pos, 1.0);
-  outColor = clip (inPos, color);
-}
diff --git a/gsk/resources/vulkan/linear-clip-rounded.vert.glsl b/gsk/resources/vulkan/linear-clip-rounded.vert.glsl
deleted file mode 100644 (file)
index b574def..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-#version 420 core
-
-#define CLIP_ROUNDED_RECT
-#include "clip.vert.glsl"
-
-struct ColorStop {
-  float offset;
-  vec4 color;
-};
-
-layout(location = 0) in vec4 inRect;
-layout(location = 1) in vec2 inStart;
-layout(location = 2) in vec2 inEnd;
-layout(location = 3) in int inRepeating;
-layout(location = 4) in int inStopCount;
-layout(location = 5) in vec4 inOffsets0;
-layout(location = 6) in vec4 inOffsets1;
-layout(location = 7) in vec4 inColors0;
-layout(location = 8) in vec4 inColors1;
-layout(location = 9) in vec4 inColors2;
-layout(location = 10) in vec4 inColors3;
-layout(location = 11) in vec4 inColors4;
-layout(location = 12) in vec4 inColors5;
-layout(location = 13) in vec4 inColors6;
-layout(location = 14) in vec4 inColors7;
-
-layout(location = 0) out vec2 outPos;
-layout(location = 1) out float outGradientPos;
-layout(location = 2) out flat int outRepeating;
-layout(location = 3) out flat int outStopCount;
-layout(location = 4) out flat ColorStop outStops[8];
-
-out gl_PerVertex {
-  vec4 gl_Position;
-};
-
-vec2 offsets[6] = { vec2(0.0, 0.0),
-                    vec2(1.0, 0.0),
-                    vec2(0.0, 1.0),
-                    vec2(0.0, 1.0),
-                    vec2(1.0, 0.0),
-                    vec2(1.0, 1.0) };
-
-float
-get_gradient_pos (vec2 pos)
-{
-  pos = pos - inStart;
-  vec2 grad = inEnd - inStart;
-
-  return dot (pos, grad) / dot (grad, grad);
-}
-
-void main() {
-  vec4 rect = clip (inRect);
-  vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
-  gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
-  outPos = pos;
-  outGradientPos = get_gradient_pos (pos);
-  outRepeating = inRepeating;
-  outStopCount = inStopCount;
-  outStops[0].offset = inOffsets0[0];
-  outStops[0].color = inColors0 * vec4(inColors0.aaa, 1.0);
-  outStops[1].offset = inOffsets0[1];
-  outStops[1].color = inColors1 * vec4(inColors1.aaa, 1.0);
-  outStops[2].offset = inOffsets0[2];
-  outStops[2].color = inColors2 * vec4(inColors2.aaa, 1.0);
-  outStops[3].offset = inOffsets0[3];
-  outStops[3].color = inColors3 * vec4(inColors3.aaa, 1.0);
-  outStops[4].offset = inOffsets1[0];
-  outStops[4].color = inColors4 * vec4(inColors4.aaa, 1.0);
-  outStops[5].offset = inOffsets1[1];
-  outStops[5].color = inColors5 * vec4(inColors5.aaa, 1.0);
-  outStops[6].offset = inOffsets1[2];
-  outStops[6].color = inColors6 * vec4(inColors6.aaa, 1.0);
-  outStops[7].offset = inOffsets1[3];
-  outStops[7].color = inColors7 * vec4(inColors7.aaa, 1.0);
-}
diff --git a/gsk/resources/vulkan/linear-clip.frag.glsl b/gsk/resources/vulkan/linear-clip.frag.glsl
deleted file mode 100644 (file)
index 1d03553..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#version 420 core
-
-struct ColorStop {
-  float offset;
-  vec4 color;
-};
-
-layout(location = 0) in float inGradientPos;
-layout(location = 1) in flat int inRepeating;
-layout(location = 2) in flat int inStopCount;
-layout(location = 3) in flat ColorStop inStops[8];
-
-layout(location = 0) out vec4 outColor;
-
-void main()
-{
-  float pos;
-  if (inRepeating != 0)
-    pos = fract (inGradientPos);
-  else
-    pos = clamp (inGradientPos, 0, 1);
-
-  vec4 color = inStops[0].color;
-  int n = clamp (inStopCount, 2, 8);
-  for (int i = 1; i < n; i++)
-    {
-      if (inStops[i].offset > inStops[i-1].offset)
-        color = mix (color, inStops[i].color, clamp((pos - inStops[i-1].offset) / (inStops[i].offset - inStops[i-1].offset), 0, 1));
-    }
-  
-  //outColor = vec4(pos, pos, pos, 1.0);
-  outColor = color;
-}
index a95b58f59bb67df32aa3c53e2b9e48ba39798e4d..86f9ea0cb42b8de137d13a7fbfcd196b0abf7660 100644 (file)
Binary files a/gsk/resources/vulkan/linear-clip.frag.spv and b/gsk/resources/vulkan/linear-clip.frag.spv differ
diff --git a/gsk/resources/vulkan/linear-clip.vert.glsl b/gsk/resources/vulkan/linear-clip.vert.glsl
deleted file mode 100644 (file)
index 1176420..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-#version 420 core
-
-#define CLIP_RECT
-#include "clip.vert.glsl"
-
-struct ColorStop {
-  float offset;
-  vec4 color;
-};
-
-layout(location = 0) in vec4 inRect;
-layout(location = 1) in vec2 inStart;
-layout(location = 2) in vec2 inEnd;
-layout(location = 3) in int inRepeating;
-layout(location = 4) in int inStopCount;
-layout(location = 5) in vec4 inOffsets0;
-layout(location = 6) in vec4 inOffsets1;
-layout(location = 7) in vec4 inColors0;
-layout(location = 8) in vec4 inColors1;
-layout(location = 9) in vec4 inColors2;
-layout(location = 10) in vec4 inColors3;
-layout(location = 11) in vec4 inColors4;
-layout(location = 12) in vec4 inColors5;
-layout(location = 13) in vec4 inColors6;
-layout(location = 14) in vec4 inColors7;
-
-layout(location = 0) out float outGradientPos;
-layout(location = 1) out flat int outRepeating;
-layout(location = 2) out flat int outStopCount;
-layout(location = 3) out flat ColorStop outStops[8];
-
-out gl_PerVertex {
-  vec4 gl_Position;
-};
-
-vec2 offsets[6] = { vec2(0.0, 0.0),
-                    vec2(1.0, 0.0),
-                    vec2(0.0, 1.0),
-                    vec2(0.0, 1.0),
-                    vec2(1.0, 0.0),
-                    vec2(1.0, 1.0) };
-
-float
-get_gradient_pos (vec2 pos)
-{
-  pos = pos - inStart;
-  vec2 grad = inEnd - inStart;
-
-  return dot (pos, grad) / dot (grad, grad);
-}
-
-void main() {
-  vec4 rect = clip (inRect);
-  vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
-  gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
-  outGradientPos = get_gradient_pos (pos);
-  outRepeating = inRepeating;
-  outStopCount = inStopCount;
-  outStops[0].offset = inOffsets0[0];
-  outStops[0].color = inColors0 * vec4(inColors0.aaa, 1.0);
-  outStops[1].offset = inOffsets0[1];
-  outStops[1].color = inColors1 * vec4(inColors1.aaa, 1.0);
-  outStops[2].offset = inOffsets0[2];
-  outStops[2].color = inColors2 * vec4(inColors2.aaa, 1.0);
-  outStops[3].offset = inOffsets0[3];
-  outStops[3].color = inColors3 * vec4(inColors3.aaa, 1.0);
-  outStops[4].offset = inOffsets1[0];
-  outStops[4].color = inColors4 * vec4(inColors4.aaa, 1.0);
-  outStops[5].offset = inOffsets1[1];
-  outStops[5].color = inColors5 * vec4(inColors5.aaa, 1.0);
-  outStops[6].offset = inOffsets1[2];
-  outStops[6].color = inColors6 * vec4(inColors6.aaa, 1.0);
-  outStops[7].offset = inOffsets1[3];
-  outStops[7].color = inColors7 * vec4(inColors7.aaa, 1.0);
-}
index 74b823059e3674a319dbcf5685ab61ac6cbe9a5d..9124ffbe413d8d5eaeb5736fcf248dd9cd7add95 100644 (file)
Binary files a/gsk/resources/vulkan/linear-clip.vert.spv and b/gsk/resources/vulkan/linear-clip.vert.spv differ
diff --git a/gsk/resources/vulkan/linear.frag b/gsk/resources/vulkan/linear.frag
new file mode 100644 (file)
index 0000000..cb7727f
--- /dev/null
@@ -0,0 +1,36 @@
+#version 420 core
+
+#include "clip.frag.glsl"
+
+struct ColorStop {
+  float offset;
+  vec4 color;
+};
+
+layout(location = 0) in vec2 inPos;
+layout(location = 1) in float inGradientPos;
+layout(location = 2) in flat int inRepeating;
+layout(location = 3) in flat int inStopCount;
+layout(location = 4) in flat ColorStop inStops[8];
+
+layout(location = 0) out vec4 outColor;
+
+void main()
+{
+  float pos;
+  if (inRepeating != 0)
+    pos = fract (inGradientPos);
+  else
+    pos = clamp (inGradientPos, 0, 1);
+
+  vec4 color = inStops[0].color;
+  int n = clamp (inStopCount, 2, 8);
+  for (int i = 1; i < n; i++)
+    {
+      if (inStops[i].offset > inStops[i-1].offset)
+        color = mix (color, inStops[i].color, clamp((pos - inStops[i-1].offset) / (inStops[i].offset - inStops[i-1].offset), 0, 1));
+    }
+  
+  //outColor = vec4(pos, pos, pos, 1.0);
+  outColor = clip (inPos, color);
+}
index a95b58f59bb67df32aa3c53e2b9e48ba39798e4d..86f9ea0cb42b8de137d13a7fbfcd196b0abf7660 100644 (file)
Binary files a/gsk/resources/vulkan/linear.frag.spv and b/gsk/resources/vulkan/linear.frag.spv differ
diff --git a/gsk/resources/vulkan/linear.vert b/gsk/resources/vulkan/linear.vert
new file mode 100644 (file)
index 0000000..f9fd57c
--- /dev/null
@@ -0,0 +1,76 @@
+#version 420 core
+
+#include "clip.vert.glsl"
+
+struct ColorStop {
+  float offset;
+  vec4 color;
+};
+
+layout(location = 0) in vec4 inRect;
+layout(location = 1) in vec2 inStart;
+layout(location = 2) in vec2 inEnd;
+layout(location = 3) in int inRepeating;
+layout(location = 4) in int inStopCount;
+layout(location = 5) in vec4 inOffsets0;
+layout(location = 6) in vec4 inOffsets1;
+layout(location = 7) in vec4 inColors0;
+layout(location = 8) in vec4 inColors1;
+layout(location = 9) in vec4 inColors2;
+layout(location = 10) in vec4 inColors3;
+layout(location = 11) in vec4 inColors4;
+layout(location = 12) in vec4 inColors5;
+layout(location = 13) in vec4 inColors6;
+layout(location = 14) in vec4 inColors7;
+
+layout(location = 0) out vec2 outPos;
+layout(location = 1) out float outGradientPos;
+layout(location = 2) out flat int outRepeating;
+layout(location = 3) out flat int outStopCount;
+layout(location = 4) out flat ColorStop outStops[8];
+
+out gl_PerVertex {
+  vec4 gl_Position;
+};
+
+vec2 offsets[6] = { vec2(0.0, 0.0),
+                    vec2(1.0, 0.0),
+                    vec2(0.0, 1.0),
+                    vec2(0.0, 1.0),
+                    vec2(1.0, 0.0),
+                    vec2(1.0, 1.0) };
+
+float
+get_gradient_pos (vec2 pos)
+{
+  pos = pos - inStart;
+  vec2 grad = inEnd - inStart;
+
+  return dot (pos, grad) / dot (grad, grad);
+}
+
+void main() {
+  vec4 rect = clip (inRect);
+  vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
+  gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
+  outPos = pos;
+  outGradientPos = get_gradient_pos (pos);
+  outRepeating = inRepeating;
+  outStopCount = inStopCount;
+  outStops[0].offset = inOffsets0[0];
+  outStops[0].color = inColors0 * vec4(inColors0.aaa, 1.0);
+  outStops[1].offset = inOffsets0[1];
+  outStops[1].color = inColors1 * vec4(inColors1.aaa, 1.0);
+  outStops[2].offset = inOffsets0[2];
+  outStops[2].color = inColors2 * vec4(inColors2.aaa, 1.0);
+  outStops[3].offset = inOffsets0[3];
+  outStops[3].color = inColors3 * vec4(inColors3.aaa, 1.0);
+  outStops[4].offset = inOffsets1[0];
+  outStops[4].color = inColors4 * vec4(inColors4.aaa, 1.0);
+  outStops[5].offset = inOffsets1[1];
+  outStops[5].color = inColors5 * vec4(inColors5.aaa, 1.0);
+  outStops[6].offset = inOffsets1[2];
+  outStops[6].color = inColors6 * vec4(inColors6.aaa, 1.0);
+  outStops[7].offset = inOffsets1[3];
+  outStops[7].color = inColors7 * vec4(inColors7.aaa, 1.0);
+}
index 8a40b6d17d1963910392100bc46c183479e2a2f6..bcc3fcf17a113c9360217523287bd3784a754232 100644 (file)
Binary files a/gsk/resources/vulkan/linear.vert.spv and b/gsk/resources/vulkan/linear.vert.spv differ